<!DOCTYPE html>
<html>
    <head>
        <include file="public:meta" />
        <link rel="stylesheet" href="../public/css/members.css">
    </head>
    <body>
        <include file="public:header" />
        <div class="split-block"></div>
        <div class="bind-top-box qs-center">
            <img src="<if condition="$user_bind_info['keyavatar_big']">{$user_bind_info.keyavatar_big}<else/>{:attach('no_photo_male.png','resource')}</if>" alt="{$user_bind_info.username}" class="b-img">
            <div class="b-nickname">{$user_bind_info.username}</div>
            <div class="font12 txt-color-9">您已登录{$third_name}账号</div>
        </div>
        <div class="split-block"></div>
        <form action="{:U('members/oauth_reg','',true,false,true)}" method="post" id="logingForm">
            <div class="b-list-group-tip">
                <div class="txt-color-3">绑定已有账号</div>
                <div class="link_blue font12 txt-color-9">如果您还没有{:C('qscms_site_name')}账号，<a href="{:U('members/bind_reg',array('openid'=>$openid),true,false,true)}">请注册并绑定</a></div>
            </div>
            <div class="list-group b-list-group">
                <div class="list_height plist-txt notarrow">
                    <div class="pic"></div>
                    <div class="tit font14">账户名</div>
                    <div class="describe font12"><input type="text" name="username" id="username" placeholder="请输入用户名/邮箱/手机号"></div>
                    <div class="arrow"></div>
                    <div class="clear"></div>
                </div>
                <div class="list_height plist-txt notarrow last">
                    <div class="pic"></div>
                    <div class="tit font14">密码</div>
                    <div class="describe font12"><input type="password" name="password" id="password" placeholder="请输入账户密码"></div>
                    <div class="arrow"></div>
                    <div class="clear"></div>
                </div>
            </div>
            <div id="pop" style="display:none"></div>
        </form>
        <input type="hidden" id="verifyLogin" value="{$verify_userlogin}">
        <input type="hidden" name="openid" value="{$openid}">
        <div class="btn-spacing mt4"><a id="bindBtn" href="javascript:;" class="qs-btn qs-btn-blue font18">绑定</a></div>
        <include file="public:footer" />
        <include file="public:footer_min" />
        <script src="http://static.geetest.com/static/tools/gt.js"></script>
    </body>
    <script>
        /**
         * 配置极验
         */
        $.ajax({
            url: qscms.root+'?m=Mobile&c=Captcha&type=mobile&t=' + (new Date()).getTime(),
            type: 'get',
            dataType: 'json',
            success: function(config) {
                initGeetest({
                    gt: config.gt,
                    challenge: config.challenge,
                    offline: !config.success
                }, function(captchaObj) {
                    captchaObj.appendTo("#pop");
                    captchaObj.onSuccess(function() {
                        doAjax();
                    });
                    window.captchaObj = captchaObj
                });
            }
        });

        /**
         * ajax 登录
         */
        function doAjax() {
            $('#logingForm').submit();
            /*$.ajax({
                url: "{:U('Members/oauth_reg')}",
                type: 'POST',
                dataType: 'json',
                data: $('#logingForm').serialize(),
                success: function(result) {
                    if (result.status) {
                        window.location.href = result.data.url;
                    } else {
                        qsToast({type:2,context: result.msg});
                    }
                },
                error: function(result) {
                    qsToast({type:2,context: result.msg});
                }
            })*/
        }

        /**
         * 绑定验证
         */
        $('#bindBtn').on('click', function () {
            var usernameValue = $.trim($('input[name=username]').val());
            var passwordValue = $.trim($('input[name=password]').val());
            if (usernameValue == '') {
                qsToast({type:2,context: '请输入账户名/手机号/邮箱'});
                return false;
            }
            if (passwordValue == '') {
                qsToast({type:2,context: '请输入密码'});
                return false;
            }
            if (eval($('#verifyLogin').val())) {
                window.captchaObj.refresh();
                $('#pop').show();
            } else {
                doAjax();
            }
        })
    </script>
</html>